
const semver = require('semver');
const process = require('child_process');
const exec = process.exec;
const packages = require('../package.json')
const packver = (packages.dependencies["element-ui"]).split('^')[1]
console.log(packver)

const test = 'npm view element-ui version'
const test1 = 'npm update element-ui --save'
exec(test, (err, stdout) => {
    if (err) {
        throw new Error(err);
    }
    // npm 线上包版本大于本地版本
    if (semver.gt(stdout, packver)) {
        fun1(test1)
    }
    console.log(stdout);
    console.log(semver.gt(stdout, packver));
});


function fun1(val){
    exec(val, (err, stdout) => {
        if (err) {
            throw new Error(err);
        }
        console.log('更新成功')
    });
}



